<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['complainservice'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['complainservice'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{ 
  $complainCallDetailArray  = array();
  $complainCount = 0;
  $msg           = "";

  $selectComplainEntry = "SELECT complainservice.complainServiceId,DATE_FORMAT(complainservice.complainDate,'%m-%d-%Y') AS complainDate,
                                 DATE_FORMAT(complainservice.targetedDate,'%m-%d-%Y') AS targetedDate,complainservice.description,complainservice.importantPoint,
                                 complainservice.serviceCharge,complainservice.remarks,complainservice.amountCollected,party.partyId,party.companyName,
                                 technician.technicianId,typeofcall.type,technician.firstName,technician.lastName,category.categoryId,category.categoryName,typeofcall.typeOfCallId
                            FROM complainservice
                            JOIN party      ON party.partyId           = complainservice.partyId
                            JOIN technician ON technician.technicianId = complainservice.technicianId
                            JOIN category   ON category.categoryId     = complainservice.categoryId
                            JOIN typeofcall ON typeofcall.typeOfCallId = complainservice.typeOfCallId";
                            
  $selectComplainEntryResult = mysql_query($selectComplainEntry);
  $complaneEntryRow = mysql_num_rows($selectComplainEntryResult);
  if($complaneEntryRow > 0)
  {
    while($complaneEntryRow = mysql_fetch_array($selectComplainEntryResult))
    {
      $complainCallDetailArray[$complainCount]['complainServiceId']  = $complaneEntryRow['complainServiceId'];
      $complainCallDetailArray[$complainCount]['companyName']        = $complaneEntryRow['companyName'];
      $complainCallDetailArray[$complainCount]['technicianName']     = $complaneEntryRow['firstName']." ".$complaneEntryRow['lastName'];
      $complainCallDetailArray[$complainCount]['categoryName']       = $complaneEntryRow['categoryName'];
      $complainCallDetailArray[$complainCount]['complainDate']       = $complaneEntryRow['complainDate'];
      $complainCallDetailArray[$complainCount]['targetedDate']       = $complaneEntryRow['targetedDate'];
      $complainCallDetailArray[$complainCount]['description']        = $complaneEntryRow['description'];
      $complainCallDetailArray[$complainCount]['importantPoint']     = $complaneEntryRow['importantPoint'];
      $complainCallDetailArray[$complainCount]['type']               = $complaneEntryRow['type'];
      $complainCallDetailArray[$complainCount]['serviceCharge']      = $complaneEntryRow['serviceCharge'];
      $complainCallDetailArray[$complainCount]['remarks']            = $complaneEntryRow['remarks'];
      $complainCallDetailArray[$complainCount]['amountCollected']    = $complaneEntryRow['amountCollected'];
      $complainCount++;
   }   
 }
 else
 {
  $msg = '<tr><td align="center" colspan="10"><h2><font color="red"><b>Record Not Found...!</b></font></h2></td></tr>';
 }
  include("./bottom.php");
  $smarty->assign("msg",$msg);
  $smarty->assign("complainCallDetailArray",$complainCallDetailArray);
  $smarty->display("complainCallList.tpl");
}
?>